package cn.xmirror.fsof.service;

import cn.xmirror.fsof.HelloService;
import com.alibaba.dubbo.common.mdc.FenqileMDC;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * <h1> TestService </h1>
 *
 * @author yuwen
 * @since 2022-07-01
 */
public class TestService {

    private HelloService demoService;

    //private GenericService demoGenericService;


    public void setDemoService(HelloService demoService) {
        this.demoService = demoService;
    }

    @RequestMapping
    public String test() {

        JSONObject jsonObject = new JSONObject();
        jsonObject.put(FenqileMDC.SERVICE_ID,"pay.m.fenqile.com/route0001/quota/get_material_list.json");
        FenqileMDC.put(FenqileMDC.EXT2,jsonObject.toJSONString());
        FenqileMDC.put(FenqileMDC.TRACE_ID, UUID.randomUUID().toString());
        //FenqileMDC.put(FenqileMDC.SPAN_ID, UUID.randomUUID().toString());
        String hello = demoService.sayHello("world-" + 1);
        System.out.println("normal call [" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] " + hello);
        return hello;
        //String bye = demoService.sayBye();
        //System.out.println("normal call [" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] " + bye);

        //Object genericHello = this.demoGenericService.$invoke("sayHello", new String[] {
        //        "java.lang.String" }, new Object[] { "world-" + 1 });
        //System.out.println("generic call [" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] " + genericHello);
        //
        //Object genericBye = this.demoGenericService.$invoke("sayBye", new String[0], new Object[0]);
        //System.out.println("generic call [" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] " + genericBye);
    }

    public void test2() {

    }
}
